/*
 * Author: 胡皇
 * Date: 2020-12-06 11:25:28
 * LastEditors: 胡皇
 * LastEditTime: 2021-03-28 14:23:27
 * Description: 
 */
const app = getApp();
const $api = require('../../../service/api.js').API;
Page({
    /**
     * 页面的初始数据
     */
    data: {
        imgUrl: app.globalData.imgUrl,
        list0: [],
        list1: [],
        list2: []
    },

    unrealDel(e){
        let that=this;
        wx.showModal({
            title: '提示',
            content: '是否删除',
            success (res) {
              if (res.confirm) {
                const data={
                    openid:wx.getStorageSync('openid'),
                    token:wx.getStorageSync('token')
                };
                const type=e.currentTarget.dataset.str_orderid;
                $api.unrealdel(type,data).then((res)=>{
                    console.log(res);
                })
                that.onShow();
              } else if (res.cancel) {
                return false;
              }
            }
          })
          
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function() {},

    getPhoneNumber(e) {
        console.log(e);
        let orid=e.currentTarget.dataset.str_orderid;
        wx.navigateTo({
            url: '../../RepairProgressPages/FeedBack/feedBack?str_orderid='+orid
        });
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function() {
      
    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {
        this.getTabBar().init();
        const token = wx.getStorageSync('token');
        if (!token) {
            wx.navigateTo({
                url: '/pages/User/Login/login'
            });
        }
        let that = this;
        $api.getAllorder(wx.getStorageSync('openid')).then((res) => {
            
            console.log(res);
            var lis0 = [],
                lis1 = [],
                lis2 = [];
            for (let i = 0; i < res.data.length; i++) {
                if (res.data[i].status == 0) {
                    lis0.push(res.data[i]);
                }
                if (res.data[i].status == 1) {
                    lis1.push(res.data[i]);
                }
                if (res.data[i].status == 2) {
                    lis2.push(res.data[i]);
                }
            }
            that.setData({
                list0: lis0,
                list1: lis1,
                list2: lis2
            });
            console.log(that.data.list0);
            console.log(that.data.list1);
            console.log(that.data.list2);
        });
    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function() {},

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function() {},

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function() {},

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function() {},

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function() {}
});